//
//  UIView+Parent.m
//  beichoo_N_ios
//
//  Created by 陈健 on 2017/9/14.
//  Copyright © 2017年 陈健. All rights reserved.
//

#import "UIView+Parent.h"

@implementation UIView (Parent)

- (UIViewController *)parentController
{    UIResponder *responder = [self nextResponder];
    while (responder) {
        if ([responder isKindOfClass:[UIViewController class]])
        {
            return (UIViewController *)responder;
        }
        responder = [responder nextResponder];
    }
    return nil;
}

- (UITableViewCell *)parentTabelViewCell {
    UIResponder *responder = [self nextResponder];
    while (responder) {
        if ([responder isKindOfClass:[UITableViewCell class]])
        {
            return (UITableViewCell *)responder;
        }
        responder = [responder nextResponder];
    }
    return nil;
}

- (UICollectionViewCell *)parentCollectionCell {
    UIResponder *responder = [self nextResponder];
    while (responder) {
        if ([responder isKindOfClass:[UICollectionViewCell class]])
        {
            return (UICollectionViewCell *)responder;
        }
        responder = [responder nextResponder];
    }
    return nil;
}

@end
